home *** CD-ROM | disk | FTP | other *** search
- /*
- Version History:
- 1.01 11/24/95
- Changed prototypes to use CP_Data's cross-platform data types.
- */
-
- #include "CP_Utils.h"
-
- void CP_SetRect(CP_Rect *destR, CP_Long left, CP_Long top, CP_Long right, CP_Long bottom) {
- destR->left = left;
- destR->top = top;
- destR->right = right;
- destR->bottom = bottom;
- } // END CP_SetRect
-
- // ---------------------------------------------------------------------------
-
- void CP_OffsetRect(CP_Rect *destR, CP_Long offsetH, CP_Long offsetV) {
- destR->top += offsetV;
- destR->bottom += offsetV;
- destR->right += offsetH;
- destR->left += offsetH;
- } // END CP_OffsetRect
-
- // ---------------------------------------------------------------------------
-
- void CP_UnionRect(const CP_Rect *rectA, const CP_Rect *rectB, CP_Rect *unionR) {
- unionR->top = CP_MIN(rectA->top, rectB->top);
- unionR->left = CP_MIN(rectA->left, rectB->left);
- unionR->bottom = CP_MAX(rectA->bottom, rectB->bottom);
- unionR->right = CP_MAX(rectA->right, rectB->bottom);
- } // END CP_UnionRect
-
- // ---------------------------------------------------------------------------
-
- void CP_CenterRect(CP_Rect *innerRect, const CP_Rect *outerRect) {
- CP_Long outerRectWidth = outerRect->right - outerRect->left;
- CP_Long outerRectHeight = outerRect->bottom - outerRect->top;
- CP_Long innerRectWidth = innerRect->right - innerRect->left;
- CP_Long innerRectHeight = innerRect->bottom - innerRect->top;
- CP_Long hDiff = (outerRectWidth - innerRectWidth) / 2;
- CP_Long vDiff = (outerRectHeight - innerRectHeight) / 2;
- innerRect->left = outerRect->left + hDiff;
- innerRect->right = innerRect->left + innerRectWidth;
- innerRect->top = outerRect->top + vDiff;
- innerRect->bottom = innerRect->top + innerRectHeight;
- } // END CP_CenterRect
-
- // ---------------------------------------------------------------------------
-
- void CP_MoveRectTo(CP_Rect *theRect, CP_Long destLeft, CP_Long destTop) {
- CP_Long width = theRect->right - theRect->left;
- CP_Long height = theRect->bottom - theRect->top;
- theRect->left = destLeft;
- theRect->top = destTop;
- theRect->right = theRect->left + width;
- theRect->bottom = theRect->top + height;
- } // END MoveRectTo
-
- // ---------------------------------------------------------------------------
-
- void CP_OffsetPoint(CP_Point *pt, CP_Long offsetH, CP_Long offsetV) {
- pt->hv.h += offsetH;
- pt->hv.v += offsetV;
- } // END CP_OffsetPoint
-
- // ---------------------------------------------------------------------------
-
- short CP_PointInRect(const CP_Point *pt, const CP_Rect *rect) {
- if ((pt->hv.h >= rect->left) &&
- (pt->hv.h <= rect->right) &&
- (pt->hv.v >= rect->top) &&
- (pt->hv.v <= rect->bottom))
- return(TRUE);
- else
- return(FALSE);
- } // END CP_PointInRect
-
- // ---------------------------------------------------------------------------